package com.example.dense_rack_server.controller;


import com.example.dense_rack_server.service.BorrowingRecordsService;
import com.example.dense_rack_server.utils.ResponseModel;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 借阅记录 前端控制器
 * </p>
 *
 * @author  张彬 
 * @since 2025-03-08
 */
@Controller
@RequestMapping("/borrowing/records")
public class BorrowingRecordsController {

    @Resource
    public BorrowingRecordsService borrowingRecordsService;

    @GetMapping("/index")
    public String index(){
        return "records/list";
    }

    /**
     * 档案操作管理list接口
     *
     * @param page
     * @param limit
     */
    @GetMapping("list")
    @ResponseBody
    public Map<String, Object> fileLogList(@RequestParam(value = "page") int page,
                                           @RequestParam(value = "limit") int limit,
                                           @RequestParam(value = "startDate",required = false) String startDate,
                                           @RequestParam(value = "endDate",required = false) String endDate,
                                           @RequestParam(value = "userName",required = false) String userName) {
        return borrowingRecordsService.fileLogList(page, limit,startDate,endDate,userName);
    }

    /**
     * 清空日志
     */
    @PostMapping("clear")
    @ResponseBody
    public ResponseModel clearLog() {
        return borrowingRecordsService.clearLog();
    }

}
